package com.yunxin.core.infra.persistence.repository.page;

import com.yunxin.core.domain.model.page.PageCache;
import com.yunxin.core.domain.model.page.PageCacheRepository;
import com.yunxin.core.infra.persistence.converter.PageConverter;
import com.yunxin.core.infra.persistence.entity.page.PageCacheDO;
import com.yunxin.core.infra.persistence.mapper.page.PageCacheExtendMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

/**
 * @author zero°
 * @since 2023-07-13
 */
@Repository
@RequiredArgsConstructor
public class PageCacheRepositoryImpl implements PageCacheRepository {

    private final PageCacheExtendMapper pageCacheExtendMapper;

    private final PageConverter pageConverter;

    @Override
    public boolean savePageCache(PageCache pageCache) {
        PageCacheDO pageCacheDO = pageConverter.fromPageCache(pageCache);
        int count = pageCacheExtendMapper.insertSelective(pageCacheDO);
        return count > 0;
    }
}
